<div class="righrs_box">
  <!-- 面包屑 -->
  <el-row>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
  </el-row>
  <!-- 添加角色按钮 -->
  <el-row class="add_box">
    <el-button @click="() => addRoulesDialog = true" type="warning">添加角色</el-button>
  </el-row>
  <el-row class="rolesList_box">
    <el-table
    :data="rolesList"
    border
    style="width: 100%">
    <el-table-column type="expand">
      <template slot-scope="data">
        <el-row class="first" v-for="first in data.row.children" :key="first.id">
          <el-col :span="4">
            <el-tag @close="deleteRightHandler(data.row.id, third.id)" closable>{{ first.authName }}</el-tag>
          </el-col>
          <el-col :span="20">
            <el-row class="second" v-for="second in first.children" :key="second.id">
              <el-col :span="4">
                <el-tag @close="deleteRightHandler(data.row.id, third.id)" closable type="warning">{{ second.authName }}</el-tag>
              </el-col>
              <el-col :span="20">
                <el-col class="third" v-for="third in second.children" :key="third.id" :span="6"> 
                    <el-tag @close="deleteRightHandler(data.row.id, third.id)" closable type="danger">{{ third.authName }}</el-tag>
                </el-col>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </template>
    </el-table-column>
    <el-table-column
      label="序号"
      width="70"
      type="index">
    </el-table-column>
    <el-table-column
      label="角色名称"
      prop="roleName"
      width="200">
    </el-table-column>
    <el-table-column
      label="角色描述"
      prop="roleDesc"
      width="250">
    </el-table-column>
    <el-table-column
      label="操作"
      width="250">
      <template slot-scope="data">
        <el-tooltip class="item" effect="dark" content="编辑" placement="top-start">
          <el-button @click="showEditInfoDialog(data.row)" type="primary" icon="el-icon-edit" circle></el-button>
        </el-tooltip>
        <el-tooltip class="item" effect="dark" content="删除" placement="top-start">
          <el-button @click="deleteRoulesHandler(data.row.id)" type="danger" icon="el-icon-delete" circle></el-button>
        </el-tooltip>
        <el-tooltip class="item" effect="dark" content="分配权限" placement="top-start">
          <el-button @click="showEditRightsHandler(data.row.children, data.row.id)" type="warning" icon="el-icon-setting" circle></el-button>
        </el-tooltip>
      </template>
    </el-table-column>
  </el-table>
  </el-row>
  <!-- 添加角色框 -->
  <el-dialog @closed="closeAddRoulesDialog" title="添加角色" :visible.sync="addRoulesDialog">
    <el-form :model="addRolesInfo"  :rules="addRolesRules" ref="addRoles" >
      <el-form-item  label="角色名称" prop="roleName" label-width="800">
        <el-input v-model="addRolesInfo.roleName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="角色描述" prop="roleDesc" label-width="800">
        <el-input v-model="addRolesInfo.roleDesc" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- 点击取消按钮 -->
      <el-button @click="() => addRoulesDialog = false " >取 消</el-button>
      <el-button @click="addRolesHandler" type="success">确认编辑</el-button>
    </div>
  </el-dialog>
  <!-- 添加编辑按钮 -->
  <el-dialog title="编辑角色" :visible.sync="editRolesInfoDialog">
    <el-form :model="editRolesInfo"  :rules="addRolesRules" ref="addRoles" >
      <el-form-item  label="角色名称" prop="roleName" label-width="800">
        <el-input v-model="editRolesInfo.roleName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="角色描述" prop="roleDesc" label-width="800">
        <el-input v-model="editRolesInfo.roleDesc" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <!-- 点击取消按钮 -->
      <el-button @click="() => editRolesInfoDialog = false">取 消</el-button>
      <el-button @click="editRolesHandler" type="success">确认编辑</el-button>
    </div>
  </el-dialog>
  <!-- 添加权限的按钮 -->
  <el-dialog  @closed="closeRightsDialog" title="分配权限" :visible.sync="editRightsDialog"> 
    <el-tree
      ref="rightsTree"
      v-if="editRightsDialog"
      :data="rightsList"
      show-checkbox
      node-key="id"
      :default-expanded-keys="expendRightsList"
      :default-checked-keys="checkedRightsList"
      :props="rightsTreeInfo">
    </el-tree>
    <div slot="footer" class="dialog-footer">
      <!-- 点击取消按钮 -->
      <el-button @click="() => this.editRightsDialog = false">取 消</el-button>
      <el-button @click="editRightHandler" type="success">确认编辑</el-button>
    </div>
  </el-dialog>
</div>